import type { Component } from 'vue';
import type { ComponentType } from './types/index';

/**
 * Component list, register here to setting it in the form
 */
import {
  Input,
  Select,
  Radio,
  Checkbox,
  Cascader,
  DatePicker,
  InputNumber,
  Switch,
  TreeSelect,
  Slider,
  Rate,
  Divider,
} from 'ant-design-vue';

import { Button } from '/@/components/Button';
import AutoComplete from 'ant-design-vue/es/auto-complete';
import TimePicker from 'ant-design-vue/es/time-picker';
import ApiRadioGroup from './components/ApiRadioGroup.vue';
import RadioButtonGroup from './components/RadioButtonGroup.vue';
import ApiSelect from './components/ApiSelect.vue';
import ApiTree from './components/ApiTree.vue';
import ApiTreeSelect from './components/ApiTreeSelect.vue';
import ApiCascader from './components/ApiCascader.vue';
import ApiTransfer from './components/ApiTransfer.vue';
import Readonly from './components/Readonly.vue';
import SubTable from './components/SubTable.vue';
import HFormTitle from '/@/components/HFormTitle';
import { BasicUpload, HUpload } from '/@/components/Upload';
import { StrengthMeter } from '/@/components/StrengthMeter';
import { IconPicker } from '/@/components/Icon';
import { CountdownInput } from '/@/components/CountDown';
import { HChooseUser } from '/@/components/HChooseUser';
import { HChooseDept } from '/@/components/HChooseDept';
import { ColorPicker } from '/@/components/ColorPicker';
import { HChooseRole } from '/@/components/HChooseRole';
import { HChoosePost } from '/@/components/HChoosePost';
import { HChooseAllUser } from '/@/components/HChooseAllUser';
import { HChooseUserBase } from '/@/components/HChooseUserBase';
import { HButtonZOffice } from '/@/components/HZOffice';
import { Map as MyMap } from '/@/components/Map';

import { HChooseComprehensiveBase } from '/@/components/HChooseComprehensiveBase';
import { CodeEditor, ButtonCodeEditor } from '/@/components/CodeEditor';

const componentMap = new Map<ComponentType, Component>();

componentMap.set('HButton', Button);
componentMap.set('Input', Input);
componentMap.set('InputGroup', Input.Group);
componentMap.set('InputPassword', Input.Password);
componentMap.set('InputSearch', Input.Search);
componentMap.set('InputTextArea', Input.TextArea);
componentMap.set('InputNumber', InputNumber);
componentMap.set('AutoComplete', AutoComplete);
componentMap.set('ColorPicker', ColorPicker);
componentMap.set('HUpload', HUpload);
componentMap.set('HChooseRole', HChooseRole);
componentMap.set('HChoosePost', HChoosePost);
componentMap.set('HChooseAllUser', HChooseAllUser);
componentMap.set('HChooseComprehensiveBase', HChooseComprehensiveBase);
componentMap.set('HChooseUserBase', HChooseUserBase);
componentMap.set('Map', MyMap);
componentMap.set('HButtonZOffice', HButtonZOffice);

componentMap.set('Select', Select);
componentMap.set('ApiSelect', ApiSelect);
componentMap.set('ApiTree', ApiTree);
componentMap.set('TreeSelect', TreeSelect);
componentMap.set('ApiTreeSelect', ApiTreeSelect);
componentMap.set('ApiRadioGroup', ApiRadioGroup);
componentMap.set('Switch', Switch);
componentMap.set('RadioButtonGroup', RadioButtonGroup);
componentMap.set('RadioGroup', Radio.Group);
componentMap.set('Checkbox', Checkbox);
componentMap.set('CheckboxGroup', Checkbox.Group);
componentMap.set('ApiCascader', ApiCascader);
componentMap.set('Cascader', Cascader);
componentMap.set('Slider', Slider);
componentMap.set('Rate', Rate);
componentMap.set('ApiTransfer', ApiTransfer);

componentMap.set('DatePicker', DatePicker);
componentMap.set('MonthPicker', DatePicker.MonthPicker);
componentMap.set('RangePicker', DatePicker.RangePicker);
componentMap.set('WeekPicker', DatePicker.WeekPicker);
componentMap.set('TimePicker', TimePicker);
componentMap.set('TimeRangePicker', TimePicker.TimeRangePicker);
componentMap.set('StrengthMeter', StrengthMeter);
componentMap.set('IconPicker', IconPicker);
componentMap.set('InputCountDown', CountdownInput);

componentMap.set('Upload', BasicUpload);
componentMap.set('Divider', Divider);
componentMap.set('HFormTitle', HFormTitle);

componentMap.set('HChooseUser', HChooseUser);
componentMap.set('HChooseDept', HChooseDept);
componentMap.set('Readonly', Readonly);
componentMap.set('SubTable', SubTable);
componentMap.set('CodeEditor', CodeEditor);
componentMap.set('ButtonCodeEditor', ButtonCodeEditor);

export function add(compName: ComponentType, component: Component) {
  componentMap.set(compName, component);
}

export function del(compName: ComponentType) {
  componentMap.delete(compName);
}

export { componentMap };
